package com.lab.cloud.common.converter.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;

import java.util.HashMap;
import java.util.Map;

public enum SexEnum implements BaseEnum {
	Male(0, "男"), FeMale(1, "女"), ManBeauty(2, "人妖");

	@EnumValue
	private int value;
	private String description;

	private static Map<Integer, SexEnum> valueMap = new HashMap<Integer, SexEnum>();

	static {
		for (SexEnum sex : SexEnum.values()) {
			valueMap.put(sex.value, sex);
		}
	}

	private SexEnum(Integer value, String description) {
		this.value = value;
		this.description = description;
	}

	@Override
	public int getValue() {
		return value;
	}

	public String getDescription() {
		return description;
	}

	@Override
	public String toString() {
		return description;
	}

	public static SexEnum getByCode(int value) {
		SexEnum result = valueMap.get(value);
		if (result == null) {
			throw new IllegalArgumentException("No element matches " + value);
		}
		return result;
	}
}
